package com.zmj.sy.mom.srv.aps.controller;

import com.zmj.sy.mom.srv.aps.bean.vo.base.*;
import com.zmj.sy.mom.srv.aps.bean.vo.importframe.*;
import com.zmj.sy.mom.srv.aps.service.ImportFrameService;
import com.zmj.sy.mom.srv.aps.utils.ApsConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;

@RequiredArgsConstructor
@Api(tags = "导入-架型")
@RestController
@RequestMapping("/importFrame")
public class ImportFrameController {

    private final ImportFrameService importFrameService;

    @ApiOperation("部件类型")
    @GetMapping("/orderType")
    public BaseSelectResVo orderType() {

        List<BaseSelectItemResVo> collect = ApsConstant.FRAME_TYPE.entrySet()
                .stream()
                .map(e -> {
                    BaseSelectItemResVo r = new BaseSelectItemResVo();
                    r.setText(e.getKey());
                    r.setValue(e.getValue());
                    return r;
                })
                .collect(Collectors.toList());

        return BaseSelectResVo.of(collect);
    }

    @ApiOperation("架型列表")
    @GetMapping("/orderList")
    public BasePageResVo<ImportFrameOrderListResVo> orderList(ImportFrameOrderListReqVo reqVo) {
        return importFrameService.orderList(reqVo);
    }

    @ApiOperation("架型选择框")
    @GetMapping("/orderSelect")
    public BaseSelectResVo orderSelect() {
        return importFrameService.orderSelect();
    }

    @ApiOperation("架型新增")
    @PostMapping("/orderAdd")
    public BaseResVo orderAdd(@RequestBody ImportFrameOrderAddReqVo reqVo) {
        importFrameService.orderAdd(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("架型编辑")
    @PostMapping("/orderEdit")
    public BaseResVo orderEdit(@RequestBody ImportFrameOrderEditReqVo reqVo) {
        importFrameService.orderEdit(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("架型删除")
    @PostMapping("/orderDel")
    public BaseResVo orderDel(@RequestBody BaseIdReqVo reqVo) {
        importFrameService.orderDel(reqVo);
        return BaseResVo.ok();
    }

//    @ApiOperation("架型-发布到MES")
//    @GetMapping("/orderPub")
//    public BaseResVo orderPub(@RequestBody ImportFrameOrderPubReqVo reqVo){
//        importFrameService.orderPub(reqVo);
//        return BaseResVo.ok();
//    }


    @ApiOperation("架型-从Erp导入模板")
    @PostMapping("/orderErp")
    public BaseResVo orderErp(@RequestBody ImportFrameOrderPubReqVo reqVo){
        importFrameService.orderErp(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("架型-从Erp导入模板")
    @PostMapping("/orderErpAppend")
    public BaseResVo orderErpAppend(@RequestBody ImportFrameOrderErpAppendReqVo reqVo){
        importFrameService.orderErpAppend(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("架型-发布到MBD")
    @PostMapping("/orderMbd")
    public BaseResVo orderMbd(@RequestBody ImportFrameOrderMbdReqVo reqVo) {
        importFrameService.orderMbd(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("架型BOM-左侧BOM树")
    @GetMapping("/bomTree")
    public BaseListResVo<ImportFrameBomTreeResVo> bomTree(BaseIdReqVo reqVo) {
        return importFrameService.bomTree(reqVo);
    }

    @ApiOperation("架型BOM-右侧列表")
    @GetMapping("/bomList")
    public BaseListResVo<ImportFrameBomListResVo> bomList(BaseIdReqVo reqVo) {
        return importFrameService.bomList(reqVo);
    }

    @ApiOperation("架型BOM-BOM新增")
    @PostMapping("/bomAdd")
    public BaseResVo bomAdd(@RequestBody ImportFrameBomAddReqVo reqVo) {
        importFrameService.bomAdd(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("架型BOM-BOM修改")
    @PostMapping("/bomEdit")
    public BaseResVo bomEdit(@RequestBody ImportFrameBomEditReqVo reqVo) {
        importFrameService.bomEdit(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("架型BOM-BOM删除")
    @PostMapping("/bomDel")
    public BaseResVo bomDel(@RequestBody BaseIdReqVo reqVo) {
        importFrameService.bomDel(reqVo);
        return BaseResVo.ok();
    }

    @ApiOperation("架型BOM-查询BOM工序")
    @GetMapping("/bomPhase")
    public BaseListResVo<ImportFrameBomPhaseResVo> bomPhase(BaseIdReqVo reqVo) {
        return importFrameService.bomPhase(reqVo);
    }

    @ApiOperation("架型BOM-工序编辑")
    @PostMapping("/phaseEdit")
    public BaseResVo phaseEdit(@RequestBody ImportFramePhaseEditReqVo reqVo) {
        importFrameService.phaseEdit(reqVo);
        return BaseResVo.ok();
    }



//    @ApiOperation("")
}
